/*
 * @lc app=leetcode.cn id=11 lang=swift
 *
 * [11] 盛最多水的容器
 */

// @lc code=start
class Solution {
    func maxArea(_ height: [Int]) -> Int {
        var l = 0, r = height.count - 1
        var area = 0
        while l < r {
            let res = (r - l) * min(height[l], height[r])
            area = max(res, area)
            if height[l] > height[r] {
                r -= 1
            } else {
                l += 1
            }
        }
        return area
    }
}
// @lc code=end

